
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import MyOrder from '@/pages/Center/myOrder'
import GroupOrder from '@/pages/Center/groupOrder'

export default [
  {
    path: '/center',
    component: () => import('@/pages/Center'),//路由懒加载方式引入组件
    meta: { isShow: true },
    children: [
      {
        path: "myorder",//不要写成  /myorder
        component: MyOrder
      },
      {
        path: "grouporder",
        component: GroupOrder
      },

      {
        path: '',
        redirect: 'myorder'//到center时，直接进入myorder路由，重定向
      }
    ]
  },
  {
    path: '/paysuccess',
    component: PaySuccess,
    meta: { isShow: true }
  },
  {
    path: '/pay',
    component: Pay,
    meta: { isShow: true },
    beforeEnter: (to, from, next) => {
      if (from.path == '/trade')
        next()
      else
        next(false)//从哪来回哪去
    }
  }
  , {
    path: '/trade',
    component: Trade,
    meta: { isShow: true },
    beforeEnter: (to, from, next) => {
      if (from.path == '/shopcart')
        next()
      else
        next(false)//从哪来回哪去
    }
  },
  {
    path: '/shopcart',
    component: ShopCart,
    meta: { isShow: true }
  },
  {
    path: "/addcartsuccess",
    name: "addcartsuccess",
    component: AddCartSuccess,
    meta: { isShow: true }
  },
  {
    name: 'detail',
    path: "/detail/:skuid",
    component: Detail,
    meta: { isShow: true }
  }
  , {
    path: '/home',
    component: () => import('@/pages/Home'),
    meta: {
      show: true
    }
  },
  {
    path: '/login',
    component: Login,
    meta: {
      show: false
    }
  },
  {
    path: '/register',
    component: Register,
    meta: {
      show: false
    }
  },
  {
    name: "search",
    path: '/search/:keyword?',//这么写,代表要传递params参数（不传url会出问题），但在后面加个问号，就代表你传与不传都可以
    component: Search,
    meta: {
      show: true
    },

  },
  {
    path: '*',//重定向,访问/时，定向到/home首页
    redirect: '/home'
  }
]